$(function () {
  let baseUrl = "http://localhost:3000";
  $(".btn").click((e) => {
    e.preventDefault();
    let username = $("#username").val();
    let password = $("#password").val();
    let checkPwd = $("#checkPwd").val();
    if (!password === checkPwd) return alert("两次密码不一致");
    $.ajax({
      url: baseUrl + "/api/reguser",
      type: "post",
      data: {
        username,
        password,
      },
      success: (res) => {
        window.location.href = "login.html";
      },
    });
  });
});
